package com.jd.ymcc.web.controller;

import com.jd.ymcc.dto.SmsImgDto;
import com.jd.ymcc.result.JSONResult;
import com.jd.ymcc.service.IVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/verifycode")
public class VerifyCodeController {

    @Autowired
    private IVerifyCodeService verifyCodeService;



    @GetMapping("/imageCode/{imageCodeKey}")
    public JSONResult image(@PathVariable("imageCodeKey")String key){

            // 调用service层获取图形验证码
            String base64Str = verifyCodeService.image(key);
            // 将获取的base64码返回给前端
            return JSONResult.success(base64Str);

    }

    @GetMapping("/sendSmsCode/{mobile}")
    public JSONResult smsVerifyCode(@PathVariable("mobile") String mobile){
        verifyCodeService.smsVerifyCode(mobile);
        return JSONResult.success();
    }
}
